#ifndef _I_API_FRAME_BUFFER_H_
#define _I_API_FRAME_BUFFER_H_

#include "../interface/I_api_RenderTargetView.h"
#include "../interface/I_api_DepthStencilView.h"

#include <vector>

class I_api_Framebuffer
{
protected:
	friend class I_api_Device;
	friend class C_gl_Device;

	std::vector<I_api_RenderTargetView *> m_pRenderTargetViewList;
	I_api_DepthStencilView * m_pDepthStencilView;

	I_api_Framebuffer(int nRenderTargetView, I_api_RenderTargetView ** ppRenderTargetView, I_api_DepthStencilView *pDepthStencilView)
	{
		if (nRenderTargetView == 0 && ppRenderTargetView == NULL && pDepthStencilView == NULL) 
		{
			m_pDepthStencilView = NULL;
			return;
		}

		m_pRenderTargetViewList.resize(nRenderTargetView);
		for (int iRTV = 0; iRTV < nRenderTargetView; iRTV++) m_pRenderTargetViewList[iRTV] = ppRenderTargetView[iRTV];

		m_pDepthStencilView = pDepthStencilView;
	}

	virtual	void	OMGetRenderTargets(int nRenderTargetView, I_api_RenderTargetView ** ppRenderTargetView, I_api_DepthStencilView ** pDepthStencilView)
	{
		*pDepthStencilView = m_pDepthStencilView;
		for (int iRTV = 0; iRTV < nRenderTargetView; iRTV++)
		{
			if (iRTV < (int) m_pRenderTargetViewList.size())
				ppRenderTargetView[iRTV] = m_pRenderTargetViewList[iRTV];

			else iRTV = nRenderTargetView;
		}
	}
	virtual	void	OMSetRenderTargets()=0;

public:
	~I_api_Framebuffer()
	{
		m_pDepthStencilView = NULL;
		m_pRenderTargetViewList.clear();
	}
};

#endif